package com.zhiliao.observer.demo1;

import java.util.Observer;
import java.util.Vector;

/**
 * 作者： zhi-liao
 * 类的作用:
 * 类的创建时间： 2021/5/23 15:48
 */
public abstract class Subject {
    private Vector<CustomObserver> obs = new Vector<CustomObserver>();
    public void addObserver(CustomObserver observer) {
        this.obs.add(observer);
    }

    public void deleteObserver(Observer observer) {
        this.obs.remove(observer);
    }

    protected void notifyObservers() {
        for (CustomObserver ob : obs) {
            ob.update();
        }
    }

    public abstract void doSomeThing();
}
